package com.example.hys.teamList;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.widget.Toast;


public class DatabaseHelper extends SQLiteOpenHelper {
    /*
     integer 整型
     real 浮点型
     primary key 主键
     autoincrement 自增长
     text 文本类型
     blob 二进制数
    */

    //建数据库建表
    public static final String CREATE_TEAM = "create table Team("
            +"team_id integer primary key autoincrement,"
            +"competition text,"
            +"cpt_category text,"
            +"team_name text,"
            +"team_leader text,"
            +"mem_number integer)";

    private Context mContext;

    public DatabaseHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
        mContext = context;
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(CREATE_TEAM);
        Toast.makeText(mContext,"Create Database Success!",Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("drop table if exists Team");
        onCreate(db);
    }
}
